package com.fsnbigdata.service.impl;
import com.fsnbigdata.service.api.EntrepreneurService;
import org.springframework.roo.addon.layers.service.annotations.RooServiceImpl;
import com.fsnbigdata.domain.Enterprise;
import com.fsnbigdata.domain.Entrepreneur;
import com.fsnbigdata.repository.EntrepreneurRepository;
import io.springlets.data.domain.GlobalSearch;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * = EntrepreneurServiceImpl
 *
 * TODO Auto-generated class documentation
 *
 */
@RooServiceImpl(service = EntrepreneurService.class)
@Service
@Transactional(readOnly = true)
public class EntrepreneurServiceImpl implements EntrepreneurService {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    private EntrepreneurRepository entrepreneurRepository;

    /**
     * TODO Auto-generated constructor documentation
     *
     * @param entrepreneurRepository
     */
    @Autowired
    public EntrepreneurServiceImpl(EntrepreneurRepository entrepreneurRepository) {
        setEntrepreneurRepository(entrepreneurRepository);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return EntrepreneurRepository
     */
    public EntrepreneurRepository getEntrepreneurRepository() {
        return entrepreneurRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param entrepreneurRepository
     */
    public void setEntrepreneurRepository(EntrepreneurRepository entrepreneurRepository) {
        this.entrepreneurRepository = entrepreneurRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param entity
     * @return Entrepreneur
     */
    @Transactional
    public Entrepreneur save(Entrepreneur entity) {
        return getEntrepreneurRepository().save(entity);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return Entrepreneur
     */
    public Entrepreneur findOne(Long id) {
        return getEntrepreneurRepository().findOne(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return Entrepreneur
     */
    public Entrepreneur findOneForUpdate(Long id) {
        return getEntrepreneurRepository().findOneDetached(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param ids
     * @return List
     */
    public List<Entrepreneur> findAll(Iterable<Long> ids) {
        return getEntrepreneurRepository().findAll(ids);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param enterprise
     * @param globalSearch
     * @param pageable
     * @return Page
     */
    public Page<Entrepreneur> findByEnterprise(Enterprise enterprise, GlobalSearch globalSearch, Pageable pageable) {
        return getEntrepreneurRepository().findByEnterprise(enterprise, globalSearch, pageable);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param enterprise
     * @return Long
     */
    public long countByEnterprise(Enterprise enterprise) {
        return getEntrepreneurRepository().countByEnterprise(enterprise);
    }

    @Override
    public List<Long> getIdsByName(String name) {
        return getEntrepreneurRepository().getIdsByName(name);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Entrepreneur> getEntityType() {
        return Entrepreneur.class;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Long> getIdType() {
        return Long.class;
    }
}
